package com.yuanluludev.app.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yuanluludev.app.R
import com.yuanluludev.imageloader.glide.GlideManager
import com.yuanluludev.lib_utils.util.SizeUtils

/**
 * yuanLuLu
 */
class TrackAdapter(data: MutableList<String>) :
    BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_track, data) {

    init {
        addChildClickViewIds(R.id.ivImage)
    }

    override fun convert(holder: BaseViewHolder, item: String) {
//        holder
//            .setText(R.id.tvSpeed, item.carPlate)
//            .setBackgroundColor(R.id.rootView, if (holder.layoutPosition % 2 == 0) ColorUtils.string2Int("#CBE5FE") else ColorUtils.string2Int("#D9EEE7"))

//        ImageLoaderManager.loadImage(item, holder.getView(R.id.ivImage) as ImageView)

//        val options = RequestOptions().placeholder(0) //加载成功之前占位图
//            .error(0) //加载错误之后的错误图
//
//        Glide.with(context)
//            .asBitmap()
//            .load(item)
//            .centerCrop()
//            .apply(options)
//            .into( holder.getView(R.id.ivImage) as ImageView)


        //1. 加载图片
//        Glide.with(context)
//            .load(item).apply(
//                RequestOptions()
//                    .transform(CenterCrop(), RoundedCorners(SizeUtils.dp2px(5F)))
//            )
//            .error(R.mipmap.ic_launcher).into(holder.getView(R.id.ivImage) as ImageView)
        GlideManager.load(context,item,holder.getView(R.id.ivImage) as ImageView)


    }

}